#include "mainwindow.h"
#include "ui_mainwindow.h"

MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
     m_spcomm = new TComm();

}

MainWindow::~MainWindow()
{
    delete ui;
    delete m_spcomm;
}

void MainWindow::on_pushButton_clicked()
{
    QString q,t;
    bool ok;
    if(m_spcomm->isOpen())
            return;

        q = ui->baudrate->currentText();
        qDebug() << q.toInt(&ok,10);

        t=ui->com->toPlainText();
        qDebug() << t;
//        m_spcomm->setBaudRate(q.toInt(&ok,10));
//        m_spcomm->setPortName(t);
        m_spcomm->setBaudRate(9600);
        m_spcomm->setPortName("com13");
        if(m_spcomm->open()==true)
            qDebug() << "打开串口";

}

void MainWindow::on_pushButton_2_clicked()
{
    if(m_spcomm->isOpen())
          m_spcomm->close();
          qDebug() << "关闭串口";

}


